package com.imonsoft.sqm.dao.basedata;

import com.imonsoft.common.httpModel.DataGrid;
import com.imonsoft.common.httpModel.Pager;
import com.imonsoft.sqm.pojo.basedata.Supplier;
import com.imonsoft.sqm.pojo.basedata.SupplierExample;
import java.util.List;
import org.springframework.orm.ibatis.support.SqlMapClientDaoSupport;
import org.springframework.stereotype.Repository;

@SuppressWarnings("deprecation")
@Repository("supplierDAO")
public class SupplierDAOImpl extends SqlMapClientDaoSupport implements SupplierDAO {

    /**
	 * This method was generated by Apache iBATIS ibator. This method corresponds to the database table ts_supplier
	 * @ibatorgenerated  Mon May 27 16:34:23 CST 2013
	 */
	public SupplierDAOImpl() {
		super();
	}

	/**
	 * This method was generated by Apache iBATIS ibator. This method corresponds to the database table ts_supplier
	 * @ibatorgenerated  Mon May 27 16:34:23 CST 2013
	 */
	public int countSupplierByExample(SupplierExample example) {
		Integer count = (Integer) getSqlMapClientTemplate().queryForObject(
				"ts_supplier.ibatorgenerated_countByExample", example);
		return count;
	}

	/**
	 * This method was generated by Apache iBATIS ibator. This method corresponds to the database table ts_supplier
	 * @ibatorgenerated  Mon May 27 16:34:23 CST 2013
	 */
	public int deleteSupplierByExample(SupplierExample example) {
		int rows = getSqlMapClientTemplate().delete(
				"ts_supplier.ibatorgenerated_deleteByExample", example);
		return rows;
	}

	/**
	 * This method was generated by Apache iBATIS ibator. This method corresponds to the database table ts_supplier
	 * @ibatorgenerated  Mon May 27 16:34:23 CST 2013
	 */
	public int deleteSupplierByPrimaryKey(Long id) {
		Supplier key = new Supplier();
		key.setId(id);
		int rows = getSqlMapClientTemplate().delete(
				"ts_supplier.ibatorgenerated_deleteByPrimaryKey", key);
		return rows;
	}

	/**
	 * This method was generated by Apache iBATIS ibator. This method corresponds to the database table ts_supplier
	 * @ibatorgenerated  Mon May 27 16:34:23 CST 2013
	 */
	public Long insertSupplier(Supplier record) {
		Object newKey = getSqlMapClientTemplate().insert(
				"ts_supplier.ibatorgenerated_insert", record);
		return (Long) newKey;
	}

	/**
	 * This method was generated by Apache iBATIS ibator. This method corresponds to the database table ts_supplier
	 * @ibatorgenerated  Mon May 27 16:34:23 CST 2013
	 */
	public Long insertSupplierSelective(Supplier record) {
		Object newKey = getSqlMapClientTemplate().insert(
				"ts_supplier.ibatorgenerated_insertSelective", record);
		return (Long) newKey;
	}

	/**
	 * This method was generated by Apache iBATIS ibator. This method corresponds to the database table ts_supplier
	 * @ibatorgenerated  Mon May 27 16:34:23 CST 2013
	 */
	@SuppressWarnings("unchecked")
	public List<Supplier> selectSupplierByExample(SupplierExample example) {
		List<Supplier> list = getSqlMapClientTemplate().queryForList(
				"ts_supplier.ibatorgenerated_selectByExample", example);
		return list;
	}

	/**
	 * This method was generated by Apache iBATIS ibator. This method corresponds to the database table ts_supplier
	 * @ibatorgenerated  Mon May 27 16:34:23 CST 2013
	 */
	public Supplier selectSupplierByPrimaryKey(Long id) {
		Supplier key = new Supplier();
		key.setId(id);
		Supplier record = (Supplier) getSqlMapClientTemplate().queryForObject(
				"ts_supplier.ibatorgenerated_selectByPrimaryKey", key);
		return record;
	}

	/**
	 * This method was generated by Apache iBATIS ibator. This method corresponds to the database table ts_supplier
	 * @ibatorgenerated  Mon May 27 16:34:23 CST 2013
	 */
	public int updateSupplierByExampleSelective(Supplier record,
			SupplierExample example) {
		UpdateByExampleParms parms = new UpdateByExampleParms(record, example);
		int rows = getSqlMapClientTemplate().update(
				"ts_supplier.ibatorgenerated_updateByExampleSelective", parms);
		return rows;
	}

	/**
	 * This method was generated by Apache iBATIS ibator. This method corresponds to the database table ts_supplier
	 * @ibatorgenerated  Mon May 27 16:34:23 CST 2013
	 */
	public int updateSupplierByExample(Supplier record, SupplierExample example) {
		UpdateByExampleParms parms = new UpdateByExampleParms(record, example);
		int rows = getSqlMapClientTemplate().update(
				"ts_supplier.ibatorgenerated_updateByExample", parms);
		return rows;
	}

	/**
	 * This method was generated by Apache iBATIS ibator. This method corresponds to the database table ts_supplier
	 * @ibatorgenerated  Mon May 27 16:34:23 CST 2013
	 */
	public int updateSupplierByPrimaryKeySelective(Supplier record) {
		int rows = getSqlMapClientTemplate().update(
				"ts_supplier.ibatorgenerated_updateByPrimaryKeySelective",
				record);
		return rows;
	}

	/**
	 * This method was generated by Apache iBATIS ibator. This method corresponds to the database table ts_supplier
	 * @ibatorgenerated  Mon May 27 16:34:23 CST 2013
	 */
	public int updateSupplierByPrimaryKey(Supplier record) {
		int rows = getSqlMapClientTemplate().update(
				"ts_supplier.ibatorgenerated_updateByPrimaryKey", record);
		return rows;
	}

	/**
	 * This class was generated by Apache iBATIS ibator. This class corresponds to the database table ts_supplier
	 * @ibatorgenerated  Mon May 27 16:34:23 CST 2013
	 */
	private static class UpdateByExampleParms extends SupplierExample {
		private Object record;

		public UpdateByExampleParms(Object record, SupplierExample example) {
			super(example);
			this.record = record;
		}

		@SuppressWarnings("unused")
		public Object getRecord() {
			return record;
		}
	}

	@SuppressWarnings("unchecked")
	@Override
	public DataGrid<Supplier> getDataGrid(SupplierExample example, Pager pager) {
		if (example == null) {
			example = new SupplierExample();
		}
		int total = countSupplierByExample(example);
		List<Supplier> rows = getSqlMapClientTemplate().queryForList("ts_supplier.ibatorgenerated_selectByExample", example, pager.getSkipResults(), pager.getRows());
		DataGrid<Supplier> dataGrid = new DataGrid<Supplier>(total, rows);
		return dataGrid;
	}

	@Override
	public List<Supplier> getAllSupplier(SupplierExample example, Pager pager) {
		if (example == null) {
			example = new SupplierExample();
		}
		int total = countSupplierByExample(example);
		List<Supplier> rows = getSqlMapClientTemplate().queryForList("ts_supplier.ibatorgenerated_selectByExample", example, pager.getSkipResults(), pager.getRows());
		return rows;
	}
}